package com.yanqu.road.server.cmd.cookboy.process3;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.cookboy.CookBoyProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.cookboy.CrossCookBoyMgr;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.C_CROSS_COOK_BOY3_OPEN_BANQUET, desc = "小当家第3阶段开宴会")
public class CrossOpenBanquetCmd extends CrossCommand {

    private long userId;
    private int activityId;
    private int itemId ;
    private UserBaseInfo userBaseInfo;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CookBoyProto.CrossCookBoy3OpenBanquetReqMsg reqMsg = CookBoyProto.CrossCookBoy3OpenBanquetReqMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        activityId = reqMsg.getActivityId();
        itemId = reqMsg.getItemId();
        userBaseInfo = PlayerBasePb.parseToUserBaseInfo(reqMsg.getPlayerBaseData());
        CrossUserMgr.updateUserBaseInfo(userId,userBaseInfo);
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        if(itemId == -1)return;
        CrossCookBoyMgr.openBanquet(activityId,serverId,userId,itemId);
    }

    @Override
    public void sendData() {

    }

}
